package com.example.demo.controller;

import com.example.demo.entity.UserEntity;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

//@Api：修饰整个类，描述Controller的作用
@Api(tags = {"我的第一个RESTful API"})
// @RestController 注解: 相当于 @Controller + @ResponseBody
@RestController
public class SwaggerController {

    //@ApiOperation：描述一个类的一个方法，或者说一个接口
    @ApiOperation(value="世界第一句编程语言")
    @RequestMapping(value={"/hello"}, method= RequestMethod.GET)
    //    @ApiParam：单个参数描述
    public String myFristSpringBoot(@ApiParam(value = "用户名") String name) {
        return "hello world " + name;
    }

    @ApiOperation(value="获取用户信息")
    @RequestMapping(value={"/getUser"}, method= RequestMethod.POST)
    public UserEntity myFristSpringBoot(UserEntity userEntity) {
        return userEntity;
    }
}
